#ifndef VSMLDELEGATE_H
#define VSMLDELEGATE_H

#include <QStyledItemDelegate>

class QListView;
class vsMLModel;
class QLineEdit;


class vsMLDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    explicit vsMLDelegate(QListView *lv, vsMLModel *m);
    ~vsMLDelegate();

    void paint(QPainter *painter, const QStyleOptionViewItem &option,
               const QModelIndex &index) const override;

    QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                          const QModelIndex &index) const override;

    void destroyEditor(QWidget *editor, const QModelIndex &index) const override;
    void setEditorData(QWidget *editor, const QModelIndex &index) const override;
    void setModelData (QWidget *editor, QAbstractItemModel *model,
                       const QModelIndex &index) const override;

    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
                              const QModelIndex &index) const override;

signals:
    void idSet(QString oldID, QString newID) const; // when user has changed a media item's id

protected:
    QListView *owner  = 0;
    vsMLModel *model  = 0;
    QLineEdit *editor = 0;
};

#endif // VSMLDELEGATE_H
